package com.autumn.zero.listing;

import java.util.Map;

import com.autumn.application.IApplicationModule;

/**
 * 默认回调上下文
 * 
 * @author 杨昌国 2018-12-18 16:43:46
 */
public class DefaultAutumnZeroListingCallbackContext implements IAutumnZeroListingCallbackContext {

	private final Map<String, IAutumnZeroListingCallback> listingCallback_Map;

	/**
	 * 实例化 AutumnZeroListingCallbackContext 类
	 */
	public DefaultAutumnZeroListingCallbackContext() {
		this.listingCallback_Map = new java.util.concurrent.ConcurrentHashMap<>(100);
	}

	@Override
	public void registerListingCallback(IAutumnZeroListingCallback listingCallback) {
		this.listingCallback_Map.put(listingCallback.getModuleId().toLowerCase(), listingCallback);
	}

	@Override
	public IAutumnZeroListingCallback getListingCallback(IApplicationModule module) {
		return this.getListingCallback(module.getModuleId());
	}

	@Override
	public IAutumnZeroListingCallback getListingCallback(String moduleId) {
		IAutumnZeroListingCallback callback = listingCallback_Map.get(moduleId.toLowerCase());
		return callback;
	}

}
